{% extends "../base.html" %}

{% block head_title %}
{{title}}
{% endblock %}

{% block head_scripts %}
{% endblock %}

{% block content %}
<p id="output"></p>
<script>
    var loc = window.location;
    var uri = 'ws:';

    if (loc.protocol === 'https:') {
      uri = 'wss:';
    }
    uri += '//{{_conf.Server.DomainSocket}}';
    uri += '/ws';

    ws = new WebSocket(uri)

    ws.onopen = function() {
      console.log('Connected')
    }

    ws.onmessage = function(evt) {
      var out = document.getElementById('output');
      out.innerHTML += evt.data + '<br>';
    }

    setInterval(function() {
      ws.send('Hello, Server!');
    }, 3000);
  </script>
{% endblock %}